<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>从上到下边框渐变示例</title>
    <style>
        body {
            margin: 0;
            padding: 40px;
            background-color: #1a1a1a;
            font-family: Arial, sans-serif;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .title {
            color: #fff;
            text-align: center;
            margin-bottom: 30px;
            font-size: 24px;
            font-weight: bold;
        }

        /* 方法一：使用SVG实现边框渐变 */
        .gradient-border-svg {
            position: relative;
            width: 100%;
            height: 100%;
            margin-bottom: 50px;
        }

        .content-box {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            font-size: 18px;
            z-index: 1;
        }

        .svg-container {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 0;
        }

        /* 方法二：使用CSS线性渐变 */
        .gradient-border-css {
            width: 100%;
            height: 100%;
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            font-size: 18px;
            margin-bottom: 50px;
        }

        .gradient-border-css::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            border: 1px solid transparent;
            border-image: linear-gradient(to bottom, #0082FF, rgba(0, 178, 213, 0.1)) 1;
            pointer-events: none;
        }

        /* 方法三：使用多个div元素 */
        .gradient-border-div {
            width: 100%;
            height: 100%;
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            font-size: 18px;
        }

        .border-top {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 1px;
            background-color: #0082FF;
        }

        .border-right {
            position: absolute;
            top: 0;
            right: 0;
            width: 1px;
            height: 100%;
            background: linear-gradient(to bottom, #0082FF, rgba(0, 178, 213, 0.1));
        }

        .border-bottom {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 1px;
            background-color: rgba(0, 178, 213, 0.1);
        }

        .border-left {
            position: absolute;
            top: 0;
            left: 0;
            width: 1px;
            height: 100%;
            background: linear-gradient(to bottom, #0082FF, rgba(0, 178, 213, 0.1));
        }

        .method-title {
            color: #0082FF;
            font-size: 18px;
            margin-bottom: 15px;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="title">从上到下边框渐变效果（1px宽度）</div>

    <!-- 方法一：SVG实现 -->
    <div class="method-title">方法一：SVG实现（最精确）</div>
    <div class="gradient-border-svg" style="width: 300px; height: 200px;">
        <div class="content-box">SVG渐变边框</div>
        <svg class="svg-container" preserveAspectRatio="none" viewBox="0 0 100 100">
            <defs>
                <linearGradient id="borderGradient" x1="0%" y1="0%" x2="0%" y2="100%">
                    <stop offset="0%" style="stop-color:#0082FF" />
                    <stop offset="100%" style="stop-color:#00B2D5;stop-opacity:0.1" />
                </linearGradient>
            </defs>
            <rect x="0.5" y="0.5" width="99" height="99" fill="none" stroke="url(#borderGradient)" stroke-width="1"/>
        </svg>
    </div>

    <!-- 方法二：CSS线性渐变 -->
    <div class="method-title">方法二：CSS border-image实现</div>
    <div style="width: 300px; height: 200px;">
        <div class="gradient-border-css">
            CSS渐变边框
        </div>
    </div>

    <!-- 方法三：多个div元素 -->
    <div class="method-title">方法三：多个div元素实现</div>
    <div style="width: 300px; height: 200px;">
        <div class="gradient-border-div">
            <div class="border-top"></div>
            <div class="border-right"></div>
            <div class="border-bottom"></div>
            <div class="border-left"></div>
            DIV渐变边框
        </div>
    </div>

    <div style="color: #fff; text-align: center; margin-top: 30px; font-size: 14px;">
        <p>三种实现方案特点：</p>
        <p><strong>方法一</strong>：SVG实现，渐变效果最精确，支持复杂路径</p>
        <p><strong>方法二</strong>：CSS border-image实现，代码简洁，但在某些浏览器可能有兼容性问题</p>
        <p><strong>方法三</strong>：多个div元素实现，兼容性最好，但代码较多</p>
    </div>
</body>
</html>